import React from 'react';
import { notification, Button } from 'antd';
import { Link } from 'react-router-dom';
import style from './index.scss';
interface IProps {
  name: string;
  link?: string; // #或空表示暂无功能
  outerLink?: string; // 外链，新的标签页
}
function LinkWithAuth(props: { data: IProps; styles?: any }) {
  const { data, styles } = props;
  const noLink = () => {
    notification.warning({ message: '功能正在开发中，请耐心等待...' });
  };
  let LinkDom;
  if (data.outerLink) {
    LinkDom = (
      <a
        style={{ ...styles }}
        className={style.href}
        href={data.outerLink}
        target="_blank"
      >
        {data.name}
      </a>
    );
  } else if (data.link === '#' || !data.link) {
    LinkDom = (
      <a style={{ ...styles }} className={style.href} onClick={noLink}>
        {data.name}
      </a>
    );
  } else if (data.link) {
    LinkDom = (
      <Link style={{ ...styles }} className={style.href} to={data.link}>
        {data.name}
      </Link>
    );
  }

  return <div> {LinkDom}</div>;
}

export default LinkWithAuth;
